package com.niit.service.impl;

import java.util.List;

import com.niit.bean.QuesReply;
import com.niit.dao.QuesReplyDao;
import com.niit.dao.impl.QuesReplyDaoImpl;
import com.niit.service.QuesReplyService;
import com.niit.utils.Page;

public class QuesReplyServiceImpl implements QuesReplyService {

	private QuesReplyDao dao = new QuesReplyDaoImpl();
	@Override
	public int add(QuesReply t) {
		return dao.add(t);
	}

	@Override
	public int delete(QuesReply t) {
		return dao.delete(t);
	}

	@Override
	public int update(QuesReply t) {
		return dao.update(t);
	}

	//java中如何将一个方法声明为过时
	@Deprecated  
	public Page<QuesReply> getPage(String pagenum, String url) {
		int total = dao.findTotal();//查出总记录数
		Page<QuesReply> page = null;
		if(pagenum == null){
			page = new Page<QuesReply>(total,1);
		}else{
			page = new Page<QuesReply>(total, Integer.parseInt(pagenum));
		}
		List<QuesReply> list = dao.findAll(page.getStartIndex(), page.getEndIndex());
		page.setList(list);
		page.setUrl(url);
		return page;
	}

	@Override
	public List<QuesReply> findByQuesId(String quesId) {
		return dao.findByQuesId(quesId);
	}

}
